<?php
/**
 * Created by PhpStorm.
 * User: 快定
 * Date: 2022/2/24
 * Time: 21:33
 */

class Factory
{
    public function create($char)
    {
        switch ($char) {
            case "A":
                return new P1();
            case "B" :
                return new P2();
            default :
                return new P1();
        }
    }
}

class P1
{

}

class P2
{

}

$A = (new Factory())->create("A");
$B = (new Factory())->create("B");
$C = clone $A;
var_dump($A);
var_dump($C);

